package com.bx.demo.web.api;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @author J
 */
@RestController
@RequestMapping("discovery")
public class DiscoveryController {

    private RestTemplate restTemplate;

    @NacosInjected
    private NamingService namingService;

    // 服务发现
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    @ResponseBody
    public List<Instance> get(@RequestParam String serviceName) throws NacosException {
//        Instance instance = namingService.selectOneHealthyInstance(serviceName);
        return namingService.getAllInstances(serviceName);
    }



}
